Skip to content

Conversation

@andredestro
Copy link
Contributor

@andredestro andredestro commented Aug 13, 2025

Description

This PR adds support for PDF files in the WebView on Android via PDF.js.

Context

https://outsystemsrd.atlassian.net/browse/RMET-2053

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • JavaScript

Tests

apk.zip

Screenshots (if appropriate)

Checklist

  • Pull request title follows the format RNMT-XXXX <title>
  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

@cssecautomation
Copy link

cssecautomation commented Aug 13, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

@andredestro
Copy link
Contributor Author

The Gradle task downloadPdfJs was added to avoid including all files related to the PDF.js library in the repository. This ensures the library is downloaded and cached during the build process, keeping the repository clean and lightweight.

@andredestro andredestro force-pushed the feat/RMET-2053/add-pdf-support branch from 06468c1 to 84abad4 Compare August 13, 2025 15:04
@andredestro andredestro marked this pull request as ready for review August 13, 2025 15:09
@andredestro andredestro changed the title feat: add support for pdf RMET-2053 :: Add Support for PDF Aug 13, 2025
@andredestro andredestro self-assigned this Aug 13, 2025
@alexgerardojacinto
Copy link
Collaborator

Note: I don't think we need to do it now, but we could possibly add unit tests for the helper methods you created (isContentTypeApplicationPdf, checkPdfByRequest, downloadPdfToCache). We could possibly move these methods to a helper class (e.g. OSIABPdfHelper) and then use then create an instance of that class to run unit tests on.

@alexgerardojacinto
Copy link
Collaborator

Results from testing in Pixel 7 and Pixel 9 Pro Android 16 devices:

  • When opening a URL for a PDF, when clearCache is true, when I close and reopen the WebView in the same PDF, the PDF opens where I had left it (same page).
  • The zoom parameter doesn't make a difference. This is probably because pdf.js has their own zoom implementation, but if it doesn't work then we should state in the documentation that the zoom option won't have an effect when the URL is for a PDF file.

@andredestro andredestro force-pushed the feat/RMET-2053/add-pdf-support branch from 535074a to 33e99a8 Compare August 14, 2025 14:44
@andredestro andredestro force-pushed the feat/RMET-2053/add-pdf-support branch from 33e99a8 to ecffb88 Compare August 14, 2025 16:26
@alexgerardojacinto alexgerardojacinto self-requested a review August 14, 2025 17:22
@alexgerardojacinto
Copy link
Collaborator

alexgerardojacinto commented Aug 14, 2025

Results of second test:

I think the OnPageNavigationCompleted event might be being triggered too often when opening a PDF. I tested opening the PDF and then scrolling down to page number 3, and this triggered the event 2 or 3 times. Is this supposed to happen?

@andredestro andredestro merged commit 73acfa1 into main Aug 18, 2025
5 of 6 checks passed
@andredestro andredestro deleted the feat/RMET-2053/add-pdf-support branch August 18, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants